/*
 * Copyright 2007 Jaisy Sprl.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package be.jaisy.ui.gwt.widget.client.viewer;

import com.google.gwt.user.client.ui.Composite;

/**
 * A viewer is a model-based adapter on a COmposite (Widget wrapper).
 * 
 * @author Stany Blanvalet <stany.blanvalet@jaisy.be>
 */
public abstract class Viewer extends Composite implements IInputProvider
{

	/**
	 * Creates a new viewer.
	 */
	protected Viewer(){
		//
	}

	/**
	 * @see be.jaisy.ui.gwt.client.jface.IInputProvider#getInput()
	 */
	public abstract Object getInput();

	/**
	 * Internal hook method called when the input to this viewer is initially set or subsequently changed.
	 * 
	 * @param input,
	 *           the new input of this viewer, or <code>null</code> if none
	 * @param oldInput
	 *           the old input element or <code>null</code> if there was previously no input
	 */
	protected abstract void inputChanged(Object input, Object oldInput);

	/**
	 * Refreshes this viewer completely with information cached from this viewer's model.
	 */
	public abstract void refresh();
	
	/**
	 * Refreshes this viewer's data completely with information cached from this viewer's model.
	 */
	public abstract void internalRefresh();

	/**
	 * Sets or clears the input for this viewer.
	 * 
	 * @param input,
	 *           the input of this viewer, or <code>null</code> if none
	 */
	public abstract void setInput(Object input);
}
